﻿function drawPlayMenu(ctx) {
    var dim = gamvas.getCanvasDimension();
    ctx.save();
    ctx.fillStyle = '#fff';
    ctx.font = 'bold 32px sans-serif';
    ctx.textAlign = 'center';
    ctx.fillText("Play Game", dim.w / 2, (dim.h / 2) - 67);
    ctx.restore();
}

function drawHighScoreMenu(ctx) {
    var dim = gamvas.getCanvasDimension();
    ctx.save();
    ctx.fillStyle = '#fff';
    ctx.font = 'bold 32px sans-serif';
    ctx.textAlign = 'center';
    ctx.fillText("High Score List", dim.w / 2, (dim.h / 2) + 50);
    ctx.restore();
}

mainMenuState = gamvas.State.extend({
    init: function () {
        // create the emitter
        this.emitter = new coinEmitter('coin');
        this.addActor(this.emitter);
        // disable screen clearing, as we draw a fullscreen image anyway
        this.autoClear = false;
        // get the background
        this.bg = new gamvas.Image(this.resource.getImage('images/mainbg.jpg'));
    },

    preDraw: function (t) {
        // draw the background before camera is applied
        this.bg.draw(t);
    },

    postDraw: function (t) {
        // draw help after camera was applied
        drawPlayMenu(this.c);
        drawHighScoreMenu(this.c);
    },

    // change to next state on space
    onKeyUp: function (k) {
        if (k == gamvas.key.SPACE) {
            gamvas.state.setState('game');
        }
        return false;
    }
});
